package com.itoffer.mapper;

import com.itoffer.pojo.*;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface CompanyMapper {

    /**
     * 通过id查询公司信息
     * @param company_id
     * @return
     */
    @Select("select * from tb_company where company_id = #{company_id};")
    Company selectCompanyInformation(int company_id);

    /**
     * 通过公司ID查询职位信息
     * @param company_id
     * @return
     */
    @Select("select * from tb_job where company_id = #{company_id}")
    Job selectJobInformationByCompanyId(int company_id);

    /**
     * 添加申请职位信息
     * @param job_id
     * @param applicant_id
     * @param apply_date
     * @return
     */
    @Insert("insert into tb_jobapply values (null,#{job_id},#{applicant_id},#{apply_date},1)")
    int addJobApply(@Param("job_id") int job_id,@Param("applicant_id") int applicant_id,@Param("apply_date") String apply_date);

    /**
     * 查询公司名和职位名
     * @param job_id
     * @return
     */
    @Select("select tb_job.job_name,tb_company.company_name from tb_job left join tb_company on tb_job.company_id = tb_company.company_id where job_id = #{job_id}")
    CompanyJobName selectJobInfoByJobId(int job_id);

    /**
     * 通过applicant_id查询个人简历的申请
     * @param applicant_id
     * @return
     */
    @Select("select * from tb_jobapply where applicant_id = #{applicant_id} ")
    List<JobApply> selectJobApplyByApplicantId(int applicant_id);

    /**
     * 根据apply_id删除表行
     * @param apply_id
     * @return
     */
    @Delete("delete from tb_jobapply where apply_id = #{apply_id}")
    int deleteJobApplyByApplyId(int apply_id);

    /**
     * 批量删除
     */

    void deleteByApplyIdS(@Param("ids") int[] ids);


    /**
     *根据applicant_id分页查询
     * @param applicant_id
     * @param begin
     * @param size
     * @return
     */
    @Select("select * from tb_jobapply where applicant_id = #{applicant_id}  limit #{begin},#{size}")
    List<JobApply> selectByPage(@Param("applicant_id")int applicant_id,@Param("begin") int begin,@Param("size") int size);

    /**
     * 查询总记录数
     * @param applicant_id
     * @return
     */
    @Select("select count(*) from tb_jobapply")
    int totalSize(int applicant_id);

}
